#include <iostream>
using namespace std;

class AA
{
public:
	AA()
	{
		this->a = 10;
	}
	void printT()
	{
		cout<<a<<endl;
	}

private:
	int a;
};

class pAA
{
public:
	pAA()
	{
		p = NULL;
	}
	pAA(AA* p)
	{
		this->p = p;
	}
	~pAA()
	{
		delete p;
	}
	AA* operator->()
	{
		return p;
	}
	AA& operator*()
	{
		return *p;
	}
	
private:
	AA *p;
};

class BB
{
public:
	BB()
	{
		p = NULL;
	}
	BB(int* p)
	{
		this->p = p;
	}
	~BB()
	{
		delete p;
	}
	int* operator->()
	{
		return p;
	}
	int& operator*()
	{
		return *p;
	}

private:
	int *p;
};

int main()
{
	AA *p = new AA;
	p->printT();  //打印10
	delete p;

	pAA myp = new AA; //构造函数
	myp->printT(); //重载操作符 ->打印10

	BB pb = new int(520);
	cout<<*pb<<endl;

}
